package com.hong.springboot.common;


import com.hong.springboot.grpc.Greeting;
import com.hong.springboot.grpc.HelloResp;
import com.hong.springboot.grpc.HelloWorldGrpc;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.stereotype.Service;

/**
 *
 * 功能描述: 客户端
 *
 * @param:
 * @return:
 * @auther: csh
 * @date: 2021/1/27 11:45
 */
@Service
public class HelloWorldClient {

    @GrpcClient("hong-grpc-client")
    private HelloWorldGrpc.HelloWorldBlockingStub blockingStub;


    public String sayHello(String name) {
        Greeting greeting = Greeting.newBuilder()
                .setName(name)
                .build();
        HelloResp resp = blockingStub.sayHello(greeting);
        return resp.getReply();
    }
}